package cn.qzbook.controller;

import cn.qzbook.domain.User;
import cn.qzbook.service.UserService;
import com.alibaba.fastjson.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/users")
public class UserController extends HttpServlet {

    private UserService userService =  new UserService();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<User> users = userService.selectUserByJDBC(null, null);

        response.setCharacterEncoding("utf-8");

        response.getWriter().write(JSONArray.toJSONString(users));

    }
}
